#define		_CRT_SECURE_NO_WARNINGS	1
#include <stdio.h>
#include <stdbool.h>

bool leapyear(int year)
{
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
	{
		return true;
	}
	else
	{
		return false;
	}
}
int getdays(int year, int month)
{
	int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int d = days[month];
	if (leapyear(year)&&month==2)
	{
		d += 1;
	}
	return d;
}
int main()
{
	int year, month;
	scanf("%d %d", &year, &month);
	int day=getdays(year, month);
	printf("%d\n", day);
	return 0;
}